package models;

import java.util.*;
import javax.persistence.*;

import play.Play;
import play.db.jpa.*;
import play.data.validation.*;

@Entity
public class Utilisateur extends Model{
    @Required	
    public String nom;
    @Required    
    public String prenom;
    public boolean prof;
    @Email
    @Required
    public String email;
    @Required    
    public String motDePasse;
    @ManyToOne
    public Groupe groupe;


    public Utilisateur(String email, String motDePasse, String nom, String prenom, boolean prof) {

    	this.email = email;
        this.motDePasse = motDePasse;
        this.nom = nom;
        this.prenom = prenom;
        this.prof = prof;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }
    
    public String getFullNom() {
        return prenom + " " + nom;
    }
    
    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public boolean isProf() {
        return prof;
    }

    public void setProf(boolean prof) {
        this.prof = prof;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getMotDePasse() {
        return motDePasse;
    }

    public void setMotDePasse(String motDePasse) {
        this.motDePasse = motDePasse;
    }

    public String findImage(){
       return    ((Play.getVirtualFile("public/images/Utilisateurs/" + this.getId() + ".jpg") != null) ? "/public/images/Utilisateurs/" + this.getId() + ".jpg" : "/public/images/Utilisateurs/profile.jpg");
    }
}